Repository navigation
feat(core): 支持 ISV 子商户身份头 x-wop-sub-mch-id 入签 - #45
Conversation
ISV D-13:build_request/execute 新增 sub_mch_id,签名前写入 x-wop-sub-mch-id 并自动纳入 signedHeaders;不传/空白 = 应用自身身份,头缺席,头集合与签名与旧版逐字节一致(AC-20)。extra_headers 携带该头等价参数,双来源同传即拒。校验:可打印 ASCII、无内部空白、trim 后 ≤128 字符。补 test_submchid.py。 Co-Authored-By: Claude Code <noreply@anthropic.com>
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
评审者指南该 PR 实现 ISV D-13 子商户身份支持:在请求签名前解析并校验 ISV 子商户请求签名时序图sequenceDiagram
participant Caller
participant Client
participant Signer
participant Gateway
Caller->>Client: build_request or execute with sub_mch_id
Client->>Client: resolve_sub_mch_id
alt valid non-blank sub_mch_id
Client->>Client: add x-wop-sub-mch-id
Client->>Signer: sign headers including x-wop-sub-mch-id
Signer-->>Client: x-wop-sign
else blank or omitted
Client->>Signer: sign legacy header set
Signer-->>Client: x-wop-sign
end
Client->>Gateway: send signed request
子商户身份输入解析流程图flowchart TD
A[Receive sub_mch_id or extra_headers] --> B{Both sources provided?}
B -- Yes --> C[Raise ConfigurationError]
B -- No --> D[resolve_sub_mch_id]
D --> E{Printable ASCII, no internal whitespace, length <= 128?}
E -- No --> C
E -- Blank after trim --> F[Omit x-wop-sub-mch-id]
E -- Valid --> G[Add x-wop-sub-mch-id before signing]
F --> H[Sign legacy header set]
G --> I[Include header in signedHeaders]
文件级变更
提示与命令与 Sourcery 交互
自定义使用体验访问你的控制面板,以便:
获取帮助Original review guide in EnglishReviewer's Guide该 PR 实现 ISV D-13 子商户身份支持:在请求签名前解析并校验 Sequence diagram for ISV sub-merchant request signingsequenceDiagram
participant Caller
participant Client
participant Signer
participant Gateway
Caller->>Client: build_request or execute with sub_mch_id
Client->>Client: resolve_sub_mch_id
alt valid non-blank sub_mch_id
Client->>Client: add x-wop-sub-mch-id
Client->>Signer: sign headers including x-wop-sub-mch-id
Signer-->>Client: x-wop-sign
else blank or omitted
Client->>Signer: sign legacy header set
Signer-->>Client: x-wop-sign
end
Client->>Gateway: send signed request
Flow diagram for sub-merchant identity input resolutionflowchart TD
A[Receive sub_mch_id or extra_headers] --> B{Both sources provided?}
B -- Yes --> C[Raise ConfigurationError]
B -- No --> D[resolve_sub_mch_id]
D --> E{Printable ASCII, no internal whitespace, length <= 128?}
E -- No --> C
E -- Blank after trim --> F[Omit x-wop-sub-mch-id]
E -- Valid --> G[Add x-wop-sub-mch-id before signing]
F --> H[Sign legacy header set]
G --> I[Include header in signedHeaders]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
嘿——我已经审阅了你的更改,整体看起来很棒!
Sourcery 评估
需要人工审阅。 错误的 x-wop-sub-mch-id 可能导致业务请求以错误的二级商户身份上下文运行,并可能在那里创建或修改记录。回滚会移除对该请求头的支持,但无法撤销网关端已经执行的操作。
Original comment in English
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. A mistaken x-wop-sub-mch-id can cause a business request to run in the wrong sub-merchant’s identity context, potentially creating or changing records there. Reverting removes the header support but does not undo any gateway-side actions already taken.
【独立复审 · fork 分支已拉本地实跑(444 用例 + 覆盖率 98.89% + AC-20 跨版本字节对比)】实现通过,合并前须更新 API 快照实跑验证(worktree @ 0b8b807,pytest 8.4.2):
逐行核对(对照 wop-specs#28 附录 J):全部吻合——
合并前须办: 2 处文字级(非阻断):
快照更新后可以合并。 |
【独立复审 · fork 分支已拉本地实跑(444 用例 + 覆盖率 98.89% + AC-20 跨版本字节对比)】实现通过,合并前须更新 API 快照实跑验证(worktree @ 0b8b807,pytest 8.4.2):
逐行核对(对照 wop-specs#28 附录 J):全部吻合——
合并前须办: 2 处文字级(非阻断):
快照更新后可以合并。 CI 触发说明:本 PR 为 fork PR,GitHub Actions 测试腿在 PR 上未触发(check rollup 仅 Sourcery/Snyk);上表「必红」均指本地按 ci.yml 同命令复跑 exit=1(同命令在 origin/main exit=0),合入后 push 侧 CI 才会真正执行该门。 |
- resolve_sub_mch_id 与 extra_headers 取值链增加 isinstance(str) 校验:
extra_headers={'x-wop-sub-mch-id': None} 此前被 str() 归一为 'None' 并静默入签,
数值入参则抛裸 TypeError;现统一构造期抛 configuration
- 去掉 extra_headers 侧 str() 强转,原值进同一校验链
- 双来源消歧改为「两侧各自按 J2 解析后再判」:空白参数不再与真实 extra 值误判为同传
- 补测试:execute 入口入签、extra_headers 空白零回归、None/数值/bytes 负例、双来源消歧
api-snapshot 门禁在 0b8b807 起即漂移(新增 build_request/execute 的 sub_mch_id 参数与 docstring 未随 PR 更新基线,该 commit 的 CI 为 action_required 未执行到)。 按 scripts/check-api-snapshot.py --update(griffe==1.14.0)重生成,无其他 API 变更。 Co-Authored-By: Claude <noreply@anthropic.com>
pytest 9.2 移除了 FixtureManager._arg2fixturedefs,pytest-bdd(含最新 9.0.0)仍引用旧名, 不锁版即 21 条 test_bdd.py 全部 AttributeError——与业务代码无关,任何分支今天跑都红。 证据:2026-10-26 最近一次全绿 run 40294534964 装的是 pytest-8.4.2 + pytest-bdd-8.1.0; 今天 run 40679072217 装到 pytest-9.2.0 + pytest-bdd-9.0.0,失败仅限 test_bdd.py(21/21)。 本地按锁定组合复跑:453 passed。 Co-Authored-By: Claude <noreply@anthropic.com>
ISV D-13:build_request/execute 新增 sub_mch_id,签名前写入 x-wop-sub-mch-id 并自动纳入 signedHeaders;不传/空白 = 应用自身身份,头缺席,头集合与签名与旧版逐字节一致(AC-20)。extra_headers 携带该头等价参数,双来源同传即拒。校验:可打印 ASCII、无内部空白、trim 后 ≤128 字符。补 test_submchid.py。
What does this PR do?
Spec compliance
Checklist
crypto-vectors.jsonis read-only)Sourcery 摘要
支持在请求构造和执行过程中使用已签名的 ISV 子商户身份,同时默认保留旧版签名行为。
新功能:
sub_mch_id参数和已签名的x-wop-sub-mch-id请求头,支持为每个请求指定 ISV 子商户身份。增强功能:
文档:
测试:
Original summary in English
Sourcery 摘要
新增对已签名的 ISV 子商户身份的支持,同时默认保留现有的请求签名行为。
新功能:
x-wop-sub-mch-id请求头指定该请求的 ISV 子商户身份。增强:
文档:
测试:
Original summary in English
Sourcery 总结
新增对已签名 ISV 子商户身份的支持,同时默认保留现有的请求签名行为。
新功能:
x-wop-sub-mch-id请求头为每个请求指定 ISV 子商户身份。改进:
CI:
文档:
测试:
Original summary in English
Summary by Sourcery
Add signed ISV sub-merchant identity support while preserving existing request signing behavior by default.
New Features:
x-wop-sub-mch-idheader in both request construction and execution.Enhancements:
CI:
Documentation:
Tests: